<?php
require_once('./classes/eveapi/class.api.php');
require_once('./classes/eveapi/class.characters.php');
require_once('./classes/eveapi/class.charactersheet.php');
require_once('./classes/eveapi/class.charselect.php'); //  Legacy function, for testing purposes only
require_once('./print-as-html.php');


$apiuser = $_POST ['apiuser'];
$apipass = $_POST ['apipwd'];

$api = new Api();
$api->setDebug(true);
$api->setUseCache(true); // that's the default, done for testing purposes
$api->setTimeTolerance(5); // also the default value
$api->setCredentials($apiuser,$apipass);

/*print("<P>Raw characters output</P>");
$dataxml = $api->getCharacters();
$data = Characters::getCharacters($dataxml);
$dataold = CharSelect::getCharacters($dataxml);
print_as_html(print_r($data,TRUE));
unset ($dataxml,$data);*/

//print("<p>Raw Character sheet data</P>");
$apicharsxml = $api->getCharacters();
$apichars = Characters::getCharacters($apicharsxml);

foreach($apichars as $index => $thischar)
{
	
		$apichar=$thischar['charid'];
		$apicorp=$thischar['corpid'];

// Set Credentials
$api->setCredentials($apiuser,$apipass,$apichar);

//print ("<P>Raw character sheet output</P>");
$dataxml = $api->getCharacterSheet();
$data = CharacterSheet::getCharacterSheet($dataxml);

$charId = $data["characterID"];
$charName = $data["name"];
$corpName = $data["corporationName"];
$corpID = $data["corporationID"];
$skillPoints = $data["cloneSkillPoints"];
$walletBallance = $data["balance"];

echo ("Character Name: " . $charName);
echo ("<br>");
echo ("Corporation Name : ");
$showinfo = "<a href=\"javascript:CCPEVE.showInfo(2,".$corpID.")\"".">".$corpName."</a>";
//$showinfo = "<a href=\"showinfo:2//".$corpID."\"".">".$corpName."</a>";
echo $showinfo;
//echo ("<br> <a href=\"showinfo:2//213725304\">Etoilles Mortant Ltd.</a> ");
//echo ("Corporation Name: " . $corpName);
echo ("<br>");
echo ("Skill Points: " . $skillPoints);
echo ("<br>");
echo ("Wallet Balance: " . $walletBallance);
echo ("<br><br><br>");

//print_as_html(print_r($data,TRUE));
}

unset ($dataxml,$data);

//$api->printErrors();

?>